#ifndef __FTP_SERVER_H__
#define __FTP_SERVER_H__

#include <stdio.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#include <string.h>
#include <stdlib.h>
#include <dirent.h>
#include <errno.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sqlite3.h>
#include <stdbool.h>

#include "protocol.h"

// #define username "lz"
// #define password "123"

struct ftplogin
{
	char usr[12];
	char pwd[12];
};

struct CLI_INFO
{
	char ip[16];
	unsigned short port;
};

#define MAX_LISTEN 128

void sighandler(int sig);

int make_tcp_server(const char *ip, unsigned short port);

void handle_connection(int confd, struct CLI_INFO *ap);

void resp_ls(int confd, char *filename);

void resp_get(int confd, char *filename);

void resp_get_folder(int confd, char *folder_path);

void resp_put(int confd, char *filename, int file_size);


void resp_rm(int confd, char *filename);

char *resp_cd(int confd,char *filename);

char *resp_pwd(int confd);

int foundUser(const char *username, FILE *file);

int resp_login(int confd);

bool verify_username_password(const char* username, const char *password);

int callback_verify_username_password(void *arg, int size, char **column_values, char **header);

int resp_login_db(int confd);
#endif
